#!/usr/bin/env python3.10
# -*- encoding: utf-8 -*-
'''
@File    :   tags.py
@Time    :   2023/05/04 18:03:26
@Author  :   windstarry 
@Version :   1.0
'''
# here put the import lib
from typing import  Optional

from fastapi import Query
from pydantic import BaseModel, Field

from .base import BaseFilter, ORMModel

__all__ = ['CreateTag', 'UpdateTag', 'TagStatus', 'TagInfo', 'TagFilter']

class CreateTag(BaseModel):
    """ 创建分类 """
    name: str = Field(..., alias='tagName')
    status: Optional[int] = 1
    description: Optional[str] = None
    

class UpdateTag(CreateTag):
    """ 更新分类 """
    pass


class TagStatus(BaseModel):
    id: int = Field(..., gt=0)
    status: int
    
    
class TagInfo(ORMModel):
    """ 分类信息 """
    id: int = Field(..., alias='tagId', description='分类ID')
    name: str = Field(..., alias='tagName', description='分类名称')


class TagFilter(BaseFilter):
    """ 过滤分类 """
    name__icontains: str = Query(None, alias='tagName')
    description__icontains: str = Query(None, alias='tagDescription')